/********************************************************************************
* File Name:	mainwindow.cpp
* Description:	第3章 实例14：DockWidget的实例
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
*
********************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTextEdit>
#include <QDockWidget>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QTextEdit *title =new QTextEdit(this);
    title->setText("Main Window");
    title->setAlignment(Qt::AlignCenter);
    this->setCentralWidget(title);

    QDockWidget *dock = new QDockWidget(tr("DockWindow 1"),this);
    dock->setFeatures(QDockWidget::DockWidgetMovable);
    dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
    QTextEdit *title1 = new QTextEdit();
    title1->setText("Window 1");
    dock->setWidget(title1);
    this->addDockWidget(Qt::LeftDockWidgetArea,dock);

    dock = new QDockWidget(tr("DockWindow 2"),this);
    dock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetClosable);
    QTextEdit *title2 = new QTextEdit();
    title2->setText("Window 2");
    dock->setWidget(title2);
    this->addDockWidget(Qt::LeftDockWidgetArea,dock);

    dock = new QDockWidget(tr("DockWindow 3"),this);
    dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
    QTextEdit *title3 = new QTextEdit();
    title3->setText("Window 3");
    dock->setWidget(title3);
    this->addDockWidget(Qt::BottomDockWidgetArea,dock);
}

MainWindow::~MainWindow()
{
    delete ui;
}
